from operator import xor
v = int(input())
a = list(map(int, input().split()))
n = 0
for i in range(1, v-1):
if a[i] > a[i + 1] and a[i] > a[i - 1]:
n += 1
elif a[i] < a[i + 1] and a[i] < a[i - 1]:
n += 1
print(n)
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n;
int a[N];
void work(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
int ans=0;
for(int i=2;i<=n-1;i++){
if(a[i-1]<a[i]&&a[i]>a[i+1]) ans++;
if(a[i-1]>a[i]&&a[i]<a[i+1]) ans++;
}
printf("%d\n",ans);
}
int main(){
work();
return 0;
}
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |